Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #389 +/- ##
=======================================
Coverage 81.94% 81.94%
=======================================
Files 21 21
Lines 853 853
Branches 87 87
=======================================
Hits 699 699
Misses 154 154 🚀 New features to boost your workflow:
|
e4af2d6 to
3824a2f
Compare
7dda968 to
cc7f3c2
Compare
|
Things done so far
List of things still to do
|
6c4d0f4 to
dbe5005
Compare
|
We should probably have a openmp specific ci without having to rely on the ld_library_path.. |
@vgvassilev Having an openmp specific ci will not avoid the need for ld_library_path. To avoid ld_library_path you would need to rework the cmake and the kernelspec (which makes reference to this variable) , and the example notebooks would need to know the path where you stored the openmp library. Using ld_library_path like xeus-clang-repl did simplifies this PR. |
45a4ee5 to
571023c
Compare
Okay, let's see if that's compatible with the vision of @SylvainCorlay which he expressed recently. |
1feccb1 to
1b1b9cd
Compare
test/test_xcpp_kernel.py
Outdated
| #include <omp.h> | ||
| #include <iostream> | ||
| #include <clang/Interpreter/CppInterOp.h> | ||
| Cpp::LoadLibrary("libomp"); |
There was a problem hiding this comment.
Cpp::LoadLibrary("libomp"); works in the notebooks, but doesn't appear to be working in the python kernel tests. I believe this because the tests fail with the same error that I get if I remove this line from the notebook (see https://github.com/compiler-research/xeus-cpp/actions/runs/18385849945/job/52383968040?pr=389#step:13:1015 for error). @vgvassilev @anutosh491 Any idea what may be going on?
There was a problem hiding this comment.
My only guess is that the kernelspecs have the flag -fopenmp=libomp , but the python output has the fopenmp flag without the =libomp (see https://github.com/compiler-research/xeus-cpp/actions/runs/18385849945/job/52383968040?pr=389#step:13:922 ). I don't know where to change it so that it has -fopenmp=libomp too though.
There was a problem hiding this comment.
Can you call the Cpp::LoadLibrary("libomp") in a separate declare operation?
There was a problem hiding this comment.
I don't know if you was suggesting splitting this code into 2 executions, one which loads the library, and one which executes the openmp code, but that has worked, and we now have a passing test. Its a simple OpenMP test, but hopefully it will suffice.
5d1ad18 to
5a2630d
Compare
|
@vgvassilev @alexander-penev @Vipul-Cariappa @anutosh491 @SylvainCorlay I now consider this PR ready for review. It adds c and c++ kernels that have openmp. It includes example notebooks for the c++ + openmp kernels taken from xeus-clang-repl which were able to run when I tried locally. It also has one simple openmp test for the jupyter kernel test tests. I wasn't exactly sure what would suffice as an automatic test, but the test clearly demonstrates the kernel is executing OpenMP code. |
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
According to these changes; The user after selecting a omp kernel, still needs to include CppInterOp.h and call Cpp::LoadLibrary(...). The user should not be expected to know the internals and do this.
When we launch a kernel that enables OpenMP, it should automatically load all necessary stuff. You need to parse the compiler arguments, check if it contains -fopenmp, if yes, call LoadLibrary.
Also, can you share the contents of kernel.json files that gets installed.
Stretch goal (may not be possible): Can we get it to work, without modifying the LD_LIBRARY_PATH env var?
|
I think I have an idea of how to avoiding needing ld library path. My new method should work on the Windows once we have that platform working too. I just need to test it out, and plan to test it out sometime in the next few days. I'm not so convinced that making the user have to include CppInterOp.h, and calling cpp::LoadLibrary(...) is as big deal as you make out to be. It would also let the user know to use other (non openmp) shared libraries in their notebooks. The example notebooks are there for a reason. I kept this PR the way xeus-clang-repl did openmp kernels. Despite this I will look into working out to have the kernel automatically do this if it notices -fopenmp in the kernel arguments. |
2dac7b4 to
a41ed55
Compare
56bb93a to
c805b83
Compare
| // FIXME: We should process the kernel input options and conditionally pass | ||
| // the gpu args here. | ||
| return Cpp::CreateInterpreter(ClangArgs/*, {"-cuda"}*/); | ||
| Cpp::TInterp_t res = Cpp::CreateInterpreter(ClangArgs /*, {"-cuda"}*/); |
There was a problem hiding this comment.
warning: no header providing "CppImpl::CreateInterpreter" is directly included [misc-include-cleaner]
Cpp::TInterp_t res = Cpp::CreateInterpreter(ClangArgs /*, {"-cuda"}*/);
^| // FIXME: We should process the kernel input options and conditionally pass | ||
| // the gpu args here. | ||
| return Cpp::CreateInterpreter(ClangArgs/*, {"-cuda"}*/); | ||
| Cpp::TInterp_t res = Cpp::CreateInterpreter(ClangArgs /*, {"-cuda"}*/); |
There was a problem hiding this comment.
warning: no header providing "CppImpl::TInterp_t" is directly included [misc-include-cleaner]
Cpp::TInterp_t res = Cpp::CreateInterpreter(ClangArgs /*, {"-cuda"}*/);
^| ) | ||
| != ClangArgs.end()) | ||
| { | ||
| Cpp::LoadLibrary("libomp"); |
There was a problem hiding this comment.
warning: no header providing "CppImpl::LoadLibrary" is directly included [misc-include-cleaner]
Cpp::LoadLibrary("libomp");
^|
Should we take the changes to the existing kernels and the I am interested in these changes but I see this PR is opened since october. |
@AntoinePrv This PR has been open for a while because certain issues needed to be resolved. I got the OpenMP kernels working, but it required a hack due to issue with CppInterOp (see this issue compiler-research/CppInterOp#784). The reason ci is currently red is because I prepared it for a new CppInterOp release which has a patch created by @Vipul-Cariappa in CppInterOp to workaround the issue. cc @vgvassilev |
| set(XEUS_CPP_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}") | ||
| set(XEUS_CPP_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include) | ||
| if(${kernel} MATCHES "omp/$") | ||
| set(XEUS_CPP_OMP "${OpenMP_CXX_FLAGS}") |
There was a problem hiding this comment.
Do we still need this? Is that the include path to openmp? I feel uncomfortable exporting that information at build time whereas it's needed at runtime and we should be able to resolve that then. However, that's not a new problem per se because we already to this for other things..
vgvassilev
left a comment
There was a problem hiding this comment.
LGTM! Consider squash on merge.
There was a problem hiding this comment.
I'll be really honest, I'm not convinced with this.
Please go through this comment of mine : #432 (comment) (especially point 2)
Just the idea of enabling OpenMP by default is not sitting well with me
Sorry for my limited capacity to look into this today (as I'm Brussels after FOSDEM & shall reach back home in India tomorrow night) but commenting at a surface level I'll just say an openmp kernel looks like a specific use case to me. And changes to the environment file/CMakelists for finding relevant paths should only be done if the user ends up wanting to build an openmp kernel right ?
I wouldn't mind it if is was not bringing in changes to the "default"
For eg all wasm kernels are SIMD enabled (which technically is a specific use case)
but it doesn't need any extra cmake changes whatsoever.
I would really like @JohanMabille or @SylvainCorlay to look at this before we take this in.
Also sorry again for missing any discussion done above as to how we proceed in the future but I see the CI is red too, so not sure we can merge.
If the parameterized JEP is the solution for handling this better: jupyter/enhancement-proposals#87
Let's just use it !
But if it's not and we if just go ahead with this and refactor later, I would like to atleast see an issue on github as to what the plan is !
I share the same sentiment, however, there is practically no way to do this as of today. We have been waiting for a solution to this issue since 2021 and I do not think it is reasonable to drop major features like openmp for this reason unfortunately.
Blocking this would also block the conda recipe and other changes proposed by Antoine because I believe they will cause more friction when this work resumes/goes in. In fact, we are moving forward and had a few emergency meetings so that we don't have to block Antoine's work and the current state of the PR is good enough. I agree this cannot go forever but that's not a good argument to disallow omp kernels -- that's one of the best use cases to teach parallel programming with xeus-cpp.
I would be more than happy to drop all kernels when this becomes widely available. @mcbarton can you open an issue to track this? |
anutosh491
left a comment
There was a problem hiding this comment.
Okay then, let's track the development here through an issue and then let's take this in !
Thank you for the explanation :)
|
It seems that we all agree that this solution is not ideal but we don't really have an alternative for now. Also this does not scale on the long run (supporting CUDA would reqiure 6 more kernels and additional dependencies for instance). I have good hope that the parametrized kernelspec JEP will be merged soon and I'll tackle its implementation in xeus right after. I think we'll also need to add a plugin system so that the additional required code (for loading libraries / initializing components / whatever) can live out of the "core" kernel. That being said, I don't think this PR is ready to merge because of the CI failures. The failing jobs should be fixed before we merge this. |
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
I too believe the CMake changes may not be required. At least the way it is implemented now. But we can track it in an issue, and fix it later.
Reasoning: OpenMP is not used by xeus-cpp itself (at least at build time), it is just an optional runtime dependency to the interpreter instance. Nowhere in xeus-cpp code we have #include <omp.h> ...
Otherwise, LGTM!
|
On the packaging end, we will probably split the conda recipe in multiple outputs (so that installing xeus-cpp does not include the OpenMP kernelspecs unless e.g. xeus-cpp-openmp is installed). I would also like to highlight that the Jupyter Enhancement Proposal was specifically created to address the C++ kernel use case. It has undergone extensive reviews, and our team produced a reference implementation covering kernel, server, and frontend components. The JEP is currently in the final voting phase. Given that the official standardization process is nearly complete, it is disappointing to rush a workaround while the long-term solution is so close to being finalized and was developed specifically with the C++ kernel in mind. |
Do we have an ETA for this? |
11473b1 to
ff4db5f
Compare
d17cf3e to
58eaaa7
Compare
a889c1b to
f7552c9
Compare
Description
Please include a summary of changes, motivation and context for this PR.
Fixes # (issue)
Type of change
Please tick all options which are relevant.